package com.misty.factory_pattern.client;

/**
 * 符合依赖倒置的原则，高层对应高层 不涉及到具体的实现类
 */
public class ProductCteator extends Creator {
    @Override
    public <T extends Product> T createProduct(Class c) {
        Product product = null;
        try {
            Class aClass = Class.forName(c.getName());
            product = (Product) aClass.newInstance();
        } catch (ClassNotFoundException | IllegalAccessException
                | InstantiationException e) {
            e.printStackTrace();
        }
        return (T) product;
    }
}
